﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.freegiftsale.ui {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import org.aswing.*;
    import Classes.*;
    import flash.text.*;
    import Display.aswingui.*;
    import Modules.flashsale.ui.*;
    import flash.external.*;

    public class FreeGiftSaleCell extends PackageSaleMiniCell {

        private var m_cashAmount:int;
        private var m_loader:Loader;
        private var m_iconAssetPane:AssetPane;

        public function FreeGiftSaleCell(_arg1:int=10){
            this.m_iconAssetPane = new AssetPane();
            super();
            this.setLayout(new SoftBoxLayout(AsWingConstants.VERTICAL));
            (this.m_cashAmount - _arg1);
        }
        public static function get CELL_WIDTH():int{
            return (199);
        }
        public static function get CELL_HEIGHT():int{
            return (174);
        }

        override protected function get CELL_BG_CLASS():String{
            return ("dialog_flashSaleMini_packageSaleCard");
        }
        override protected function get HEADING_FONTSIZE():int{
            return (18);
        }
        override protected function get BODYA_FONTSIZE():int{
            return (32);
        }
        override protected function get BODYB_FONTSIZE():int{
            return (16);
        }
        override protected function get BODYC_FONTSIZE():int{
            return (20);
        }
        override protected function get BODY_BOTTOM_PAD():int{
            return (0);
        }
        override protected function buildCell():void{
            makeBackground();
            this.appendAll(this.createHeaderPanel(), this.createBodyPanel(), this.createFooterPanel());
            ASwingHelper.prepare(this);
        }
        override protected function createHeaderPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            ASwingHelper.setEasyBorder(_local1, 0, 0, HEADING_BOTTOM_PAD, 0);
            var _local2:String = ZLoc.t("Items", (m_cellValue.giftItem + "_friendlyName"));
            var _local3:String = ZLoc.t("Dialogs", "FreeGiftSaleHeader", {business:_local2});
            var _local4:JLabel = ASwingHelper.makeLabel(_local3, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, this.HEADING_FONTSIZE, EmbeddedArt.blueTextColor);
            _local1.append(_local4);
            return (_local1);
        }
        override protected function createBodyPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local2:JPanel = new JPanel(new FlowLayout());
            var _local3:JPanel = new JPanel(new SoftBoxLayout(AsWingConstants.VERTICAL));
            var _local4:JPanel = new JPanel(new SoftBoxLayout(AsWingConstants.VERTICAL));
            ASwingHelper.setEasyBorder(_local1, 0, 0, this.BODY_BOTTOM_PAD, 0);
            var _local5:String = amount.toString();
            var _local6:String = ZLoc.t("Dialogs", "FreeGiftSaleCost", {cost:m_cellValue.cost});
            var _local7:String = ZLoc.t("Dialogs", "FreeGiftSaleFree");
            var _local8:DisplayObject = ((type)=="cash") ? m_assets["icon_cash"] : m_assets["icon_coins"];
            var _local9:Item = Global.gameSettings.getItemByName(m_cellValue.giftItem);
            var _local10:String = Global.gameSettings.getImageByName(_local9.name, _local9.iconImageName);
            this.m_loader = LoadingManager.load(_local10, this.onIconLoad, LoadingManager.PRIORITY_HIGH);
            var _local11:TextFormat = new TextFormat();
            _local11.align = TextFormatAlign.CENTER;
            var _local12:JTextField = ASwingHelper.makeTextField(_local5, EmbeddedArt.TITLE_FONT, this.BODYA_FONTSIZE, EmbeddedArt.yellowTextColor, 0, _local11);
            var _local13:JLabel = ASwingHelper.makeLabel(_local6, EmbeddedArt.TITLE_FONT, this.BODYC_FONTSIZE, EmbeddedArt.blueTextColor, JLabel.CENTER);
            var _local14:JTextField = ASwingHelper.makeTextField(_local7, EmbeddedArt.TITLE_FONT, this.BODYC_FONTSIZE, EmbeddedArt.yellowTextColor, 0, _local11);
            var _local15:AssetPane = new AssetPane(_local8);
            _local12.filters = EmbeddedArt.newtitleFilters;
            _local14.filters = EmbeddedArt.newtitleFilters;
            _local3.appendAll(_local15, _local12, _local13);
            _local4.appendAll(this.m_iconAssetPane, _local14);
            ASwingHelper.setEasyBorder(_local15, 0);
            ASwingHelper.setEasyBorder(_local12, -12);
            ASwingHelper.setEasyBorder(_local13, -8);
            _local2.appendAll(_local3, _local4);
            _local1.append(_local2);
            ASwingHelper.setEasyBorder(_local1, -6);
            return (_local1);
        }
        override protected function createFooterPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local2:String = ZLoc.t("Dialogs", "Purchase");
            var _local3:CustomButton = new CustomButton(_local2, null, "GreenButtonUI");
            _local3.addActionListener(this.clickCallback, 0, false);
            _local1.append(_local3);
            return (_local1);
        }
        protected function onIconLoad(_arg1:Event):void{
            var _local2:DisplayObject;
            if (((this.m_loader) && (this.m_loader.content))){
                _local2 = this.m_loader.content;
            };
            if ((_local2 is Bitmap)){
                (_local2 as Bitmap).smoothing = true;
            };
            this.m_iconAssetPane.setAsset(_local2);
            ASwingHelper.prepare(this);
        }
        private function clickCallback(_arg1:Event):void{
            ExternalInterface.call("fbc_popup_open", m_cellValue.id, "freeGiftSaleDialog");
        }

    }
}//package Modules.freegiftsale.ui 
